package com.project.util;

import java.io.FileReader;
import java.io.IOException;
import java.util.Properties;

public class Factory {
    private static Properties pro = new Properties();
    static{
        try {
            pro.load(new FileReader("dao.txt"));
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    public static Object getBean(String interfaceName){
        String value = pro.getProperty(interfaceName);

        try {
            Class c = Class.forName(value);
            return c.getConstructor().newInstance();
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
}
